package web.components;

import java.io.IOException;
import java.util.Set;

import javax.faces.component.FacesComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

@FacesComponent("PinComponent")
public class PinComponent extends UIComponentBase {

	@Override
	public String getFamily() {
		return "Pin";
	}

	@Override
	public void encodeBegin(FacesContext context) throws IOException { 
		ResponseWriter writer = context.getResponseWriter();
		String locname = (String) this.getAttributes().get("locname");
		int locid = (Integer) this.getAttributes().get("locid");
		int xCoord = (Integer) this.getAttributes().get("xCoord");
		int yCoord = (Integer) this.getAttributes().get("yCoord");
		System.out.println("("+locid+") Pin: "+locname+" ["+xCoord+","+yCoord+"]");
		writer.write("pins = pins.concat(new Pindata("+xCoord+", "+yCoord+", "+locid+", '"+locname+"'));");
	}
}
